<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>申请的自习室</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
</head>
<body>
<table id="demo" lay-filter="test"></table>

<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script>
    layui.use(['table', 'layer', 'jquery'], function () {
        var table = layui.table;
        var layer = layui.layer;
        let $ = layui.jquery;


        table.render({
            elem: '#demo',
            height: 'auto',
            url: '/studyRoom/getApplyResultsByStu', //数据接口,
            page: true, //开启分页
            cols: [[ //表头
                {field: 'roomApplyId', title: '申请编号', width: "10%",},
                {field: 'studyroomId', title: '自习室编号', width: "10%",templet:function (data) {
                        return data.studyRooms.studyroomId;
                    }},
                {field: 'studyroomNumber', title: '自习室楼号', width: "10%",templet:function (data) {
                        return data.studyRooms.studyroomNumber;
                    }},
                {field: 'startTime', title: '开始使用时间', width: "13%"},
                {field: 'closeTime', title: '结束使用时间', width: "13%"},
                {field: 'status', title: '状态', width: "10%",templet:function (data){
                        if (data.status==='1'){
                            return '已通过';
                        }else if (data.status==='2'){
                            return '未通过';
                        }else {
                            return '等待中';
                        }
                    }},
            ]],
            response: {
                statusCode: 200 ,//规定成功的状态码，默认：0
            },
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            }
        });

    })
</script>
</body>
</html>